﻿@model MyMvc.Model.Models.Article
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>添加相关文档</title>
     @*多文档上传*@
    <script src="~/Scripts/jquery-1.7.1.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

     <script type="text/javascript">
         function AfterAbout(data) {
             if (data == "OK") {
                 //调用父容器的一个方法，关闭对话框
                 window.parent.AfterSetAdd();
             }
             else {
                 alert("出错了，请您检查");
             }
         }
    </script>
</head>
<body>
   <h3>您正在给文章:<font color="red" size="5">@Model.Title </font>添加相关文章:</h3>
     <hr />
        <fieldset>
         
             @using (Ajax.BeginForm("AboutArticle", "Literature", new AjaxOptions() { OnSuccess = "AfterAbout" }, new { id = "addframe1" }))
             {
                 //存放一个隐藏域用来给前台传递ID
                 <input type="hidden" name="hidUserId" value="@Model.ID" />
                
                 <legend>请选择您需要添加的相关文章</legend>
             
                 //获取后台传递过来的Article对象，并且进行转换
                 List<MyMvc.Model.Models.Article> allArticles = (List<MyMvc.Model.Models.Article>)ViewBag.AllArticles;
                 List<int> ExistIds = (List<int>)ViewBag.ExtistArticleIds;
                 for (int i = 0; i < allArticles.Count; i++)
                 {
                     if (i % 5 == 0)
                     {
                          <br />
                     }
                     string str = "ckb_" + allArticles[i].ID;
                     string name="name_"+allArticles[i].Title;
                     if (ExistIds.Contains(allArticles[i].ID))
                     {
                        <input type="checkbox" checked="checked" name="@str"  id="@str" value="@str" /> 
                     }
                     else
                     {
                        <input type="checkbox"  id="@str" name="@str" value="@str" />  
                     }
                    <label for="@str">@allArticles[i].Title</label><span>&nbsp;&nbsp;</span>
                 }
                 <br />
                <div style="text-align:center;">
                    <input type="submit" value="设置相关文章" />
                </div>
             }
        </fieldset>

     <br />
</body>
</html>